//
//  ThreeDPublishViewController.m
//  ShrimpCrowdordering
//
//  Created by jimmy on 2018/8/24.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "ThreeDPublishViewController.h"
#import "ShareView.h"
#import <TencentOpenAPI/QQApiInterface.h>
#import <TencentOpenAPI/TencentOAuth.h>
#import "WeiboSDK.h"
#import "WXApi.h"
#import "UIButton+HCBState.h"
#import "GradientColorTool.h"
#import "ThreeDPublishCell.h"
#import "UIView+Utils.h"
#import "ModelingPublishVC.h"
#import "CenterAlertView.h"
#import "GKCover.h"
#import "CommitOrderViewController.h"
#import "WishListViewController.h"
#import "PersonShowView.h"

@interface ThreeDPublishViewController ()<UITableViewDelegate,UITableViewDataSource,TencentSessionDelegate,UIScrollViewDelegate>

@property (nonatomic, strong) TencentOAuth   * tencentOAuth;
@property (nonatomic,strong)  BaseTableView  * tableView;
///三方分享的View
@property (nonatomic, strong) ShareView      * shareView;
@property (nonatomic, strong) UIButton       * shadowBtn;

@property (nonatomic,strong)  NSArray    * sexStrArr;
///选中的性别的序列
@property (nonatomic,assign)  NSInteger  sexTypeIndex;
///选中的年龄的序列(儿童，少年，青年之类的标题序列)
@property (nonatomic,assign)  NSInteger  ageIndex;
///选中的季节的序列
@property (nonatomic,assign)  NSInteger  seasonTypeIndex;
///选中的类型的序列
@property (nonatomic,assign)  NSInteger  typeTypeIndex;
///选中的类型 中 款型的序列
//@property (nonatomic,assign)  NSInteger  styleTypeIndex;
///选中的尺寸的序列
@property (nonatomic,assign)  NSInteger  sizeTypeIndex;
///选中的配饰的序列
@property (nonatomic,assign)  NSInteger  accessoriesTypeIndex;
///选中的场景的序列
@property (nonatomic,assign)  NSInteger  bjTypeIndex;
///选中的频道的序列
@property (nonatomic,assign)  NSInteger  channelTypeIndex;

///选中的性别的字符串
@property (nonatomic,copy)  NSString    *   sexStr;
///选中的年龄的字符串
@property (nonatomic,copy)  NSString    *    ageStr;
///选中的季节的字符串
@property (nonatomic,copy)  NSString    *    seasonStr;
///选中的类型的字符串
@property (nonatomic,copy)  NSString    *    typeStr;
///选中的尺寸的字符串
@property (nonatomic,copy)  NSString    *    sizeStr;
///选中的配饰的字符串
@property (nonatomic,copy)  NSString    *    accessorieStr;
///选中的场景的字符串
@property (nonatomic,copy)  NSString    *    bjStr;
///选中的频道的字符串
@property (nonatomic,copy)  NSString    *    channelStr;

@property (nonatomic,copy)  NSString    *    channelId;
///存放选择类型的数组
@property (nonatomic,strong)  NSMutableArray        * typeTitleArray;

///左边放置按钮的View
@property (nonatomic,strong)  UIView         * leftBtnView;
///左边放置的按钮tag 1000+
@property (nonatomic,strong)  UIButton       * leftButton;
///左边选中的按钮
@property (nonatomic,strong)  UIButton       * selectButton;
///右边放置按钮的View
@property (nonatomic,strong)  UIView         * rightBtnView;
///右边放置的按钮tag 2000+
@property (nonatomic,strong)  UIButton       * rightButton;
///选中的类型的序数
@property (nonatomic,assign)  NSInteger        typeInt;

///选择年龄选中的按钮
@property (nonatomic,strong)  UIButton       * ageSelectBtn;
///默认选中的 第几个 年龄类型
@property (nonatomic,assign)  NSInteger        ageSelectNum;
///选择款型 后的 选择类型 选中的按钮
@property (nonatomic,strong)  UIButton       * typeSelectBtn;
///默认选中的 第几个 选择类型
@property (nonatomic,assign)  NSInteger        typeSelectNum;
///选择款型 后的 选择款型 选中的按钮
@property (nonatomic,strong)  UIButton       * styleSelectBtn;
///默认选中的 第几个 选择款型
@property (nonatomic,assign)  NSInteger        styleSelectNum;
///选择配饰 后的 选中的按钮
@property (nonatomic,strong)  UIButton       * accessorySelectBtn;
///默认选中的 第几个 选择类型
@property (nonatomic,assign)  NSInteger        accessorySelectNum;
///选择场景 后的 选中的按钮
@property (nonatomic,strong)  UIButton       * bjSelectBtn;
///默认选中的 第几个 选择款型
@property (nonatomic,assign)  NSInteger        bjSelectNum;

///选中年龄的类型是第几个（每个年龄段里选择的是哪个）
@property (nonatomic, assign) NSInteger        ageTypeIndex;
///存放年龄 的样式的数组
@property (nonatomic, strong) NSMutableArray * ageDataAry;
///年龄Id
@property (nonatomic, strong) NSMutableArray * ageIdDataAry;
///年龄图片
@property (nonatomic, strong) NSMutableArray * ageImageDataAry;
///存放年龄图片Id的数组
@property (nonatomic, strong) NSMutableArray * modelPicIdArray;
///存放模型ID的数组
@property (nonatomic, strong) NSMutableArray * modelIdArray;
///存放模型头部的数组
@property (nonatomic, strong) NSMutableArray * headPicDataAry;
///存放模型身体的数组
@property (nonatomic, strong) NSMutableArray * bodyPicDataAry;
///存放模型脚的数组
@property (nonatomic, strong) NSMutableArray * footPicDataAry;

///存放选择类型 的样式的数组
@property (nonatomic, strong) NSMutableArray * typeSelectArray;
///款型图片
@property (nonatomic, strong) NSMutableArray * modelImageDataAry;
///款型Id
@property (nonatomic, strong) NSMutableArray * modelIdDataAry;
///存放选择款型 的样式的数组
@property (nonatomic, strong) NSMutableArray * styleSelectArray;

/// 存放尺码的数组
@property (nonatomic, strong) NSMutableArray * sizeDataAry;

/// 存放配饰的数组
@property (nonatomic, strong) NSMutableArray * accessoryDataAry;
/// 存放配饰图片的数组
@property (nonatomic, strong) NSMutableArray * accessoryImageDataAry;
/// 存放配饰图片的id数组
@property (nonatomic, strong) NSMutableArray * accessoryIdDataAry;

/// 存放场景的数组
//@property (nonatomic, strong) NSMutableArray * bjDataArray;
/// 存放场景图片的数组
@property (nonatomic, strong) NSMutableArray * bjImageDataArray;
/// 存放场景Id的数组
//@property (nonatomic, strong) NSMutableArray * bjIdDataArray;

/// 存放频道的数组
@property (nonatomic, strong) NSMutableArray * channelDataArray;
/// 存放频道图片的数组
@property (nonatomic, strong) NSMutableArray * channelImageDataArray;
/// 存放频道Id的数组
@property (nonatomic, strong) NSMutableArray * channelIdDataArray;

///年龄scrollView
@property (nonatomic,strong) UIScrollView *ageBjScroll;
///类型scrollView
@property (nonatomic,strong) UIScrollView *typeBjScroll;
///款式scrollView
@property (nonatomic,strong) UIScrollView *styleBjScroll;
///配饰scrollView
@property (nonatomic,strong) UIScrollView *accessoryBjScroll;

@property (nonatomic,strong)  PersonShowView *bjImageView;

///年龄的总数组（里面是所有年龄段的数据）需要处理的
@property (nonatomic,strong)  NSArray  * ageArr;
///类型的总数组（里面是所有类型的数据）需要处理的
@property (nonatomic,strong)  NSArray  * typeArr;
///配饰的总数组（里面是所有配饰的数据）需要处理的
@property (nonatomic,strong)  NSArray  * accessoryArr;
///需要传到下个界面的图片Id数组（建模必传 年龄模型图片ID，款型图片ID，配饰图片ID）
@property (nonatomic,strong)  NSMutableArray  * picIdsArray;
///是否是智能设计（随机搭配）
@property (nonatomic,assign)  BOOL    isRandom;
///是否保存
@property (nonatomic,assign)  BOOL    isSave;

///存放本地保存设计的字典
@property (nonatomic,strong)  NSMutableDictionary  * localDict;

@end

@implementation ThreeDPublishViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:nil];
    [self.shadowBtn removeFromSuperview];
    [self.shareView removeFromSuperview];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self setTitle:@"建模"];
    [self updateData];

    [self setTableViewUI];
    [self setHeaderViewUI];
    
}

#pragma mark - 初始化 数据
-(void)updateData
{
    self.isRandom = NO;
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"保存设计"]) {
        self.isSave = YES;
    }
    self.isSave = NO;
    self.typeInt = 0;
    self.typeSelectNum = 0;
    self.styleSelectNum = 0;
    self.sexTypeIndex = 0;
    self.ageTypeIndex = 0;
    self.typeTypeIndex = 0;
    self.seasonTypeIndex = 0;
    self.bjTypeIndex = 0;
    self.sizeTypeIndex = 0;
    self.accessoriesTypeIndex = 0;
    self.channelTypeIndex = 0;
    
    self.sexStr = @"男";
    self.seasonStr = @"春";
    
    self.typeTitleArray = [@[@"男",@"年龄",@"春",@"款型",@"尺码",@"配饰",@"场景",@"频道"] mutableCopy];
    self.sexStrArr = @[@"男",@"女"];
    self.ageArr = [NSArray array];
    self.typeSelectArray = [NSMutableArray array];
    self.modelImageDataAry = [NSMutableArray array];
    self.modelIdDataAry = [NSMutableArray array];
    self.styleSelectArray = [NSMutableArray array];
    
    self.sizeDataAry = [NSMutableArray array];
    
    self.accessoryDataAry = [NSMutableArray array];
    self.accessoryImageDataAry = [NSMutableArray array];
    self.accessoryIdDataAry = [NSMutableArray array];
    
    self.bjImageDataArray = [NSMutableArray array];
    
    self.channelDataArray = [NSMutableArray array];
    self.channelImageDataArray = [NSMutableArray array];
    self.channelIdDataArray = [NSMutableArray array];
    
    self.ageIdDataAry = [NSMutableArray array];
    self.modelPicIdArray = [NSMutableArray array];
    self.ageDataAry = [NSMutableArray array];
    self.ageImageDataAry = [NSMutableArray array];
    self.modelIdDataAry = [NSMutableArray array];
    self.headPicDataAry = [NSMutableArray array];
    self.bodyPicDataAry = [NSMutableArray array];
    self.footPicDataAry = [NSMutableArray array];
    
    self.picIdsArray = [@[@"1",[NSMutableArray array],@"3"] mutableCopy];
    
    self.localDict = [NSMutableDictionary dictionary];
}

#pragma mark - 请求频道数据
- (void)getChannelDataFormServer
{
    NSLog(@"%@",kNSUDefaultReadKey(@"userId"));
    __weak __typeof(self) weakSelf = self;
    NSString *channelListUrl = [NSString stringWithFormat:@"%@api/channelList",REQUESTHEADER];
    NSDictionary *dict = @{@"userId":kNSUDefaultReadKey(@"userId")};
    [HttpManager postHttpRequestByGet:channelListUrl andParameter:dict success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            for (NSDictionary *dic in successResponse[@"data"][@"list"]) {
                [weakSelf.channelImageDataArray addObject:dic[@"pic"]];
                [weakSelf.channelDataArray addObject:dic[@"name"]];
                [weakSelf.channelIdDataArray addObject:dic[@"id"]];
            }
            weakSelf.channelTypeIndex = 0;
            [weakSelf.typeTitleArray removeObjectAtIndex:7];
            [weakSelf.typeTitleArray insertObject:self.channelDataArray[weakSelf.channelTypeIndex] atIndex:7];
            weakSelf.channelStr = weakSelf.channelDataArray[weakSelf.channelTypeIndex];
            weakSelf.channelId = weakSelf.channelIdDataArray[weakSelf.channelTypeIndex];
            [[weakSelf.view viewWithTag:1007] setTitle:self.channelDataArray[weakSelf.channelTypeIndex] forState:UIControlStateNormal];
            NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:0];
            [weakSelf.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationNone];
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

#pragma mark - 请求尺码数据
- (void)getSizeDataFormServerWithAgeId:(NSInteger )ageId
{
    __weak __typeof(self) weakSelf = self;
    NSString *sizeListUrl = [NSString stringWithFormat:@"%@api/getModelSize",REQUESTHEADER];
    NSDictionary *ageIdDict = @{@"ageId":@(ageId)};
    [HttpManager postHttpRequestByGet:sizeListUrl andParameter:ageIdDict success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            weakSelf.sizeDataAry = successResponse[@"data"][@"list"];
            
            weakSelf.sizeTypeIndex = 0;
            [weakSelf.typeTitleArray removeObjectAtIndex:4];
            [weakSelf.typeTitleArray insertObject:self.sizeDataAry[weakSelf.sizeTypeIndex] atIndex:4];
            weakSelf.sizeStr = self.sizeDataAry[weakSelf.sizeTypeIndex];
            [[weakSelf.view viewWithTag:1004] setTitle:self.sizeDataAry[weakSelf.sizeTypeIndex] forState:UIControlStateNormal];
            NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:0];
            [weakSelf.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationNone];
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

#pragma mark - 请求年龄数据
- (void)getAgeDataFormServerWithSexStr:(NSString *)sexStr
{
    if (!sexStr) {
        [HttpManager showNoteMsg:@"请选择性别"];
    }
    __weak __typeof(self) weakSelf = self;

    NSString *ageListUrl = [NSString stringWithFormat:@"%@api/getModelAge",REQUESTHEADER];
    NSDictionary *dict = @{@"sex":sexStr};
    [HttpManager postHttpRequestByGet:ageListUrl andParameter:dict success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            
            weakSelf.ageArr = successResponse[@"data"][@"list"];
            [weakSelf.ageIdDataAry removeAllObjects];
            [weakSelf.ageDataAry removeAllObjects];
            for (NSDictionary *dic in successResponse[@"data"][@"list"]) {
                [weakSelf.ageIdDataAry addObject:dic[@"ageId"]];
                [weakSelf.ageDataAry addObject:dic[@"name"]];
            }
            [weakSelf.tableView reloadData];
            if (weakSelf.ageDataAry.count > 0 && [weakSelf.ageArr[0][@"pics"] count] > 0) {
                [weakSelf.bjImageView setAge:self.ageDataAry[0]];
                
                weakSelf.ageStr = weakSelf.ageDataAry[0];
                UIButton * btn = [weakSelf.view viewWithTag: 1001];
                [btn setTitle:weakSelf.ageStr forState:UIControlStateNormal];
                
                weakSelf.ageTypeIndex = 0;
                weakSelf.ageSelectNum = 0;
                [weakSelf.bjImageView setAge:self.ageDataAry[weakSelf.ageSelectNum]];
                [weakSelf.bjImageView setHeadWithImage:weakSelf.ageArr[weakSelf.ageSelectNum][@"pics"][weakSelf.ageTypeIndex][@"head"]];
                [weakSelf.bjImageView setClothesWithImage:weakSelf.ageArr[weakSelf.ageSelectNum][@"pics"][weakSelf.ageTypeIndex][@"body"]];
                [weakSelf.bjImageView setTrousersWithImage:weakSelf.ageArr[weakSelf.ageSelectNum][@"pics"][weakSelf.ageTypeIndex][@"foot"]];
                [weakSelf.picIdsArray replaceObjectAtIndex:0 withObject:weakSelf.ageArr[weakSelf.ageSelectNum][@"pics"][weakSelf.ageTypeIndex][@"id"]];
            }
            
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

#pragma mark - 请求款型数据
- (void)getTypeDataFormServerWithAgeId:(NSInteger)ageId
{
    __weak __typeof(self) weakSelf = self;
    NSString *typeListUrl = [NSString stringWithFormat:@"%@api/getModelType",REQUESTHEADER];
    NSDictionary *dict = @{@"ageId":@(ageId)};//self.ageIdDataAry[self.ageSelectNum]
    [HttpManager postHttpRequestByGet:typeListUrl andParameter:dict success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            weakSelf.typeArr = successResponse[@"data"][@"list"];
            [weakSelf.typeSelectArray removeAllObjects];
            
            for (NSDictionary *dic in successResponse[@"data"][@"list"]) {
                //衣服类型
                [weakSelf.typeSelectArray addObject:dic[@"className"]];
            }
            NSMutableArray *arr = weakSelf.picIdsArray[1];
            if (arr.count == 0) {
                for (NSDictionary *typeDict in self.typeArr) {
                    [arr addObject:@""];
                }
                [weakSelf.picIdsArray replaceObjectAtIndex:1 withObject:arr];
            }
            
            if (weakSelf.isRandom) {
                [weakSelf.typeTitleArray removeObjectAtIndex:3];
                weakSelf.typeStr = @"套装";
                [weakSelf.typeTitleArray insertObject:weakSelf.typeStr atIndex:3];
                [[weakSelf.view viewWithTag:1003] setTitle:weakSelf.typeStr forState:UIControlStateNormal];
                
                if (weakSelf.typeArr.count == 0) {
                    [HttpManager showNoteMsg:@"暂无该性别年龄段款式"];
                }
                for (int i = 0; i < weakSelf.typeArr.count; i++) {
                    NSDictionary *typeDict = weakSelf.typeArr[i];
                    if ([typeDict[@"className"] isEqualToString:@"上衣"]) {
                        //随机搭配衣服
                        int a = arc4random() % [typeDict[@"typeNames"] count];//上衣类别的随机数
                        NSArray *arr = typeDict[@"typeNames"][a][@"typePics"];
                        int b = arc4random() % (arr.count);//上衣的随机数
                        
                        NSMutableArray *array = [NSMutableArray arrayWithArray:weakSelf.picIdsArray[1]];
                        [array replaceObjectAtIndex:i withObject:arr[b][@"picId"]];
                        [weakSelf.picIdsArray replaceObjectAtIndex:1 withObject:array];
                        
                        [weakSelf.localDict setValue:arr[b][@"pic"] forKey:@"typeImage"];
                        [weakSelf.bjImageView setClothesWithImage:arr[b][@"pic"]];
                    }else if ([typeDict[@"className"] isEqualToString:@"下衣"]) {
                        //随机搭配衣服
                        int a = arc4random() % [typeDict[@"typeNames"] count];//下衣类别的随机数
                        NSArray *arr = typeDict[@"typeNames"][a][@"typePics"];
                        int b = arc4random() % (arr.count);//下衣的随机数
                        
                        NSMutableArray *array = [NSMutableArray arrayWithArray:weakSelf.picIdsArray[1]];
                        [array replaceObjectAtIndex:i withObject:arr[b][@"picId"]];
                        [weakSelf.picIdsArray replaceObjectAtIndex:1 withObject:array];
                        
                        [weakSelf.localDict setValue:arr[b][@"pic"] forKey:@"styleImage"];
                        [weakSelf.bjImageView setTrousersWithImage:arr[b][@"pic"]];
                    }
                }
                weakSelf.isRandom = NO;
            }else {
                [weakSelf.modelImageDataAry removeAllObjects];
                [weakSelf.modelIdDataAry removeAllObjects];
                [weakSelf.styleSelectArray removeAllObjects];
                if (weakSelf.typeArr.count > 0) {
                    weakSelf.typeSelectNum = 0;
                    
                    NSDictionary *typaDict = self.typeArr[0];
                    //款式类型（短袖长袖，短裤长裤之类的）
                    NSArray *typeNamesArr = [typaDict valueForKey:@"typeNames"];
                    for (NSDictionary *dict in typeNamesArr) {
                        //款式类型
                        [weakSelf.styleSelectArray addObject:dict[@"typeName"]];
                        for (NSDictionary *imageAndIdDict in dict[@"typePics"]) {
                            //图片数组
                            [weakSelf.modelImageDataAry addObject:imageAndIdDict[@"pic"]];
                            [weakSelf.modelIdDataAry addObject:imageAndIdDict[@"picId"]];
                        }
                    }
                    
                    weakSelf.styleSelectNum = 0;
                    
                    [weakSelf.typeTitleArray removeObjectAtIndex:3];
                    weakSelf.typeStr = [weakSelf.typeSelectArray[weakSelf.typeSelectNum] stringByAppendingString:weakSelf.styleSelectArray[weakSelf.styleSelectNum]];
                    [weakSelf.typeTitleArray insertObject:weakSelf.typeStr atIndex:3];
                    [[weakSelf.view viewWithTag:1003] setTitle:weakSelf.typeStr forState:UIControlStateNormal];
                    
                    weakSelf.typeTypeIndex = 0;
                    if ([weakSelf.typeSelectArray[weakSelf.typeSelectNum] isEqualToString:@"上衣"]) {
                        [weakSelf.localDict setValue:weakSelf.modelImageDataAry[0] forKey:@"typeImage"];
                        [weakSelf.bjImageView setClothesWithImage:weakSelf.modelImageDataAry[0]];
                    }else if ([weakSelf.typeSelectArray[weakSelf.typeSelectNum] isEqualToString:@"下衣"]) {
                        [weakSelf.localDict setValue:weakSelf.modelImageDataAry[0] forKey:@"styleImage"];
                        [weakSelf.bjImageView setTrousersWithImage:weakSelf.modelImageDataAry[0]];
                    }
                    NSMutableArray *arr = [NSMutableArray arrayWithArray:weakSelf.picIdsArray[1]];
                    [arr replaceObjectAtIndex:0 withObject:weakSelf.modelIdDataAry[0]];
                    [weakSelf.picIdsArray replaceObjectAtIndex:1 withObject:arr];
                }
            }
            
            NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:0];
            [weakSelf.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationNone];
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

#pragma mark - 请求配饰数据
- (void)getAccessoryDataFormServer
{
    __weak __typeof(self) weakSelf = self;
    NSString *accessorylListUrl = [NSString stringWithFormat:@"%@api/getModelOrnament",REQUESTHEADER];
    [HttpManager postHttpRequestByGet:accessorylListUrl andParameter:nil success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            
            weakSelf.accessoryArr = successResponse[@"data"][@"list"];
            for (NSDictionary *dic in self.accessoryArr) {
                [weakSelf.accessoryDataAry addObject:dic[@"name"]];
            }
            
            NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:0];
            [weakSelf.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationNone];
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

#pragma mark - 请求场景数据
- (void)getModelBackDataFormServer
{
    __weak __typeof(self) weakSelf = self;
    NSString *bjListUrl = [NSString stringWithFormat:@"%@api/getModelBack",REQUESTHEADER];
    [HttpManager postHttpRequestByGet:bjListUrl andParameter:nil success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            //  将请求到的数据赋给场景图片数组（数组里面是所有场景图片）
            weakSelf.bjImageDataArray = successResponse[@"data"][@"list"];
            weakSelf.bjTypeIndex = 0;
            //  设置默认场景是场景图片中的第一张
            [weakSelf.bjImageView setBackGroundWithImage:self.bjImageDataArray[0]];
            
            [weakSelf.tableView reloadData];
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

#pragma mark - 设置tableView
-(void)setTableViewUI
{
    self.tableView = [[BaseTableView alloc] initWithFrame:CGRectMake(0, -NAVIGATION_BAR_HEIGHT , SCREEN_WIDTH, SCREEN_HEIGHT)];//- ScreenX375(20)//+ScreenX375(20)
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
}

#pragma mark - 设置headerView
-(void)setHeaderViewUI
{
    UIButton *shareBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(44), STATUS_BAR_HEIGHT, ScreenX375(44), ScreenX375(44))];
    [shareBtn setImage:ImageWithName(@"分享") forState:UIControlStateNormal];
    shareBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 5, 0, -5);
    [shareBtn addTarget:self action:@selector(share) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:shareBtn];
    
    UIView *bjView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScreenX375(480))];
    bjView.tag = 999;
    
    self.bjImageView = [[PersonShowView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScreenX375(470))];
    [bjView addSubview:self.bjImageView];
    
    //判断 如果是保存设计过，就直接把保存设计的东西展示出来
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"保存设计"]) {
        NSDictionary * dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"保存设计"];
        if ([dict[@"isSave"] integerValue] == YES) {
            self.localDict = [NSMutableDictionary dictionaryWithDictionary:dict];
            if (dict[@"sex"]) {
                self.sexStr = dict[@"sex"];
                [self.bjImageView setSex:dict[@"sex"]];
                [self.typeTitleArray replaceObjectAtIndex:0 withObject:dict[@"sex"]];
            }
            if (dict[@"ageStr"]) {
                self.ageStr = dict[@"ageStr"];
                [self.bjImageView setAge:dict[@"ageStr"]];
                [self.typeTitleArray replaceObjectAtIndex:1 withObject:dict[@"ageStr"]];
            }
            if (dict[@"seasonStr"]) {
                self.seasonStr = dict[@"seasonStr"];
                [self.typeTitleArray replaceObjectAtIndex:2 withObject:dict[@"seasonStr"]];
            }
            if (dict[@"typeStr"] && dict[@"styleStr"]) {
                self.typeStr = [NSString stringWithFormat:@"%@%@",dict[@"typeStr"],dict[@"styleStr"]];
                [self.typeTitleArray replaceObjectAtIndex:3 withObject:[NSString stringWithFormat:@"%@%@",dict[@"typeStr"],dict[@"styleStr"]]];
            }
            if (dict[@"sizeStr"]) {
                self.sizeStr = dict[@"sizeStr"];
                [self.typeTitleArray replaceObjectAtIndex:4 withObject:dict[@"sizeStr"]];
            }
            if (dict[@"accessoryStr"]) {
                self.accessorieStr = dict[@"accessoryStr"];
                [self.typeTitleArray replaceObjectAtIndex:5 withObject:dict[@"accessoryStr"]];
            }
            if (dict[@"channelStr"]) {
                self.channelStr = dict[@"channelStr"];
                [self.typeTitleArray replaceObjectAtIndex:7 withObject:dict[@"channelStr"]];
            }
            if (dict[@"channelId"]) {
                self.channelId = [NSString stringWithFormat:@"%@",dict[@"channelId"]];
            }
            if (dict[@"head"]) {
                [self.bjImageView setHeadWithImage:dict[@"head"]];
            }
            if (dict[@"body"]) {
                [self.bjImageView setClothesWithImage:dict[@"body"]];
            }
            if (dict[@"foot"]) {
                [self.bjImageView setTrousersWithImage:dict[@"foot"]];
            }
            if (dict[@"typeImage"]) {
                [self.bjImageView setClothesWithImage:dict[@"typeImage"]];
            }
            if (dict[@"styleImage"]) {
                [self.bjImageView setTrousersWithImage:dict[@"styleImage"]];
            }
            if (dict[@"bjImage"]) {
                [self.bjImageView setBackGroundWithImage:dict[@"bjImage"]];
            }
            if (dict[@"picIdsArray"]) {
                self.picIdsArray = [NSMutableArray arrayWithArray:dict[@"picIdsArray"]];
            }
        }
    }else {
        [self getAgeDataFormServerWithSexStr:@"男"];//获取年龄段数据
        [self.bjImageView setSex:@"男"];
        [self getChannelDataFormServer];//获取频道数据
        [self getModelBackDataFormServer];//获取背景数据
        [self getAccessoryDataFormServer];//获取配饰数据
    }
    self.tableView.tableHeaderView = bjView;
    
    if (!self.leftBtnView) {
        self.leftBtnView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/4, ScreenX375(470))];
        [bjView addSubview:self.leftBtnView];
        
        for (int i = 0; i < self.typeTitleArray.count; i ++) {
            self.leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
            self.leftButton.frame = CGRectMake(ScreenX375(18), ScreenX375(84)+ScreenX375(21)*(i+1)+ScreenX375(22)*i , ScreenX375(60), ScreenX375(22));
            self.leftButton.tag = 1000 + i;
            self.leftButton.titleLabel.font = Kfont(12);
            self.leftButton.layer.masksToBounds = YES;
            self.leftButton.layer.cornerRadius = 11;
            self.leftButton.layer.borderWidth = 1;
            [self.leftButton hcb_setborderColor:FONTCOLOR_LIGHTGRAY forState:UIControlStateNormal animated:NO];
            [self.leftButton hcb_setborderColor:REXADECIMALCOLOR(@"#f21934") forState:UIControlStateSelected animated:NO];
            [self.leftButton setTitle:self.typeTitleArray[i] forState:UIControlStateNormal];
            [self.leftButton setTitleColor:FONTCOLOR_BLACK forState:UIControlStateNormal];
            [self.leftButton setTitleColor:REXADECIMALCOLOR(@"#f21934") forState:UIControlStateSelected];
            if (i == 0) {
                self.leftButton.selected = YES;
                self.selectButton = self.leftButton;
            }
            [self.leftButton addTarget:self action:@selector(selectBtnClick:) forControlEvents:UIControlEventTouchUpInside];
            
            [self.leftBtnView addSubview:self.leftButton];
        }
    }
    [self setRightBtnViewUI];
}

#pragma mark - 选中左边button后的点击事件
-(void)selectBtnClick:(UIButton *)button
{
    self.sexStr = self.sexStrArr[self.sexTypeIndex];
    if (button.tag == 1001) {
        if (!self.sexStr) {
            [HttpManager showNoteMsg:@"请选择性别"];
            return;
        }
    }

    if (button.tag == 1003) {
        if (!self.ageStr) {
            [HttpManager showNoteMsg:@"请选择年龄段"];
            return;
        }
    }
    if (button.tag == 1004) {
        if (!self.ageStr) {
            [HttpManager showNoteMsg:@"请选择年龄段"];
            return;
        }
    }

    NSLog(@"buttonTag----%ld",button.tag);
    //默认选中的是第一个，当点击别的按钮的时候，要给选中的按钮的选中状态去掉
    self.selectButton.selected = NO;
    //此时点击的这个按钮的状态要改变为选中状态
    button.selected = YES;
    //此时选中的按钮就是当前点击的这个按钮了
    self.selectButton = button;
    //记录当时所选的 第几个按钮
    self.typeInt = button.tag - 1000;
    [self.tableView reloadData];
    NSLog(@"typeInt----%ld",self.typeInt);
    
    
    if (self.typeInt != 0) {
        [[self.view viewWithTag:1000] setTitle:self.sexStr forState:UIControlStateNormal];
    }

    if (self.typeInt == 1) {
        [self getAgeDataFormServerWithSexStr:self.sexStr];
        
    }
    
    if (self.typeInt == 3) {
        [self getTypeDataFormServerWithAgeId:[self.picIdsArray[0] integerValue]];
    }
    
    if (self.typeInt == 4) {
        [self getSizeDataFormServerWithAgeId:[self.picIdsArray[0] integerValue]];
    }
    
    if (self.typeInt == 5) {
        [self getAccessoryDataFormServer];
    }
    
    if (self.typeInt == 6) {
        [self getModelBackDataFormServer];
    }
    
    if (self.typeInt == 7) {
        [self getChannelDataFormServer];
    }
}

#pragma mark - 右边button的View
-(void)setRightBtnViewUI
{
    if (!self.rightBtnView) {
        self.rightBtnView = [[UIView alloc] initWithFrame:CGRectMake(3*SCREEN_WIDTH/4, 0, SCREEN_WIDTH/4, ScreenX375(470))];
        [[self.view viewWithTag:999] addSubview:self.rightBtnView];
        NSArray *titleArray = @[@"保存设计",@"智能设计",@"心愿订单",@"立即购买",@"发布作品"];
        for (int i = 0; i < titleArray.count; i ++) {
            self.rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
            self.rightButton.frame = CGRectMake(ScreenX375(0), ScreenX375(127)+ScreenX375(21)*(i+1)+ScreenX375(22)*i , ScreenX375(75), ScreenX375(22));
            self.rightButton.tag = 2000 + i;
            self.rightButton.titleLabel.font = Kfont(12);
            self.rightButton.layer.masksToBounds = YES;
            self.rightButton.layer.cornerRadius = 11;
            self.rightButton.backgroundColor = UIColorFromRGB(@"#ff1062", 1);
            [self.rightButton setTitle:titleArray[i] forState:UIControlStateNormal];
            [self.rightButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [self.rightButton addTarget:self action:@selector(selectRightBtnClick:) forControlEvents:UIControlEventTouchUpInside];
            
            [self.rightBtnView addSubview:self.rightButton];
        }
    }
}

#pragma mark -选中右边按钮的点击事件
-(void)selectRightBtnClick:(UIButton *)button
{
    __weak __typeof(self) weakSelf = self;
    NSLog(@"buttonTag----%ld",button.tag - 2000);
    if (button.tag == 2001){
        CenterAlertView *view = [CenterAlertView centerAlertView];//WithAlertText:@"已为你量身定做一套衣服"
        view.label.text = @"已为你量身定做一套衣服";
        view.seeDetailBtn.hidden = YES;
        [GKCover centerCover:view style:GKCoverStyleTranslucent notClick:true animated:true];
        
        self.isRandom = YES;
        if (self.ageIdDataAry.count == 0) {
            return;
        }
        [self getTypeDataFormServerWithAgeId:[self.ageIdDataAry[self.ageSelectNum] integerValue]];
    }
 
    if (button.tag == 2000) {
        CenterAlertView *view = [CenterAlertView centerAlertView];//WithAlertText:@"保存成功"
        view.label.text = @"保存成功!";
        view.seeDetailBtn.hidden = YES;
        self.isSave = YES;
       
        //将选择好的东西保存到本地，下次进入就直接展示
        [self.localDict setValue:@(YES) forKey:@"isSave"];
        [self.localDict setValue:self.sexStr forKey:@"sex"];
        if (self.ageDataAry.count > self.ageSelectNum) {
            [self.localDict setValue:self.ageDataAry[self.ageSelectNum] forKey:@"ageStr"];
            [self.localDict setValue:self.ageArr[self.ageSelectNum][@"pics"][self.ageTypeIndex][@"head"] forKey:@"head"];
            [self.localDict setValue:self.ageArr[self.ageSelectNum][@"pics"][self.ageTypeIndex][@"body"] forKey:@"body"];
            [self.localDict setValue:self.ageArr[self.ageSelectNum][@"pics"][self.ageTypeIndex][@"foot"] forKey:@"foot"];
        }
        [self.localDict setValue:self.seasonStr forKey:@"seasonStr"];
        [self.localDict setValue:self.sizeStr forKey:@"sizeStr"];
        
        if (self.typeSelectArray.count > self.typeSelectNum) {
            [self.localDict setValue:self.typeSelectArray[self.typeSelectNum] forKey:@"typeStr"];
        }
        
        if (self.styleSelectArray.count > self.styleSelectNum) {
            [self.localDict setValue:self.styleSelectArray[self.styleSelectNum] forKey:@"styleStr"];
        }
        
        if (self.accessoryDataAry.count > self.accessorySelectNum) {
            [self.localDict setValue:self.accessoryDataAry[self.accessorySelectNum] forKey:@"accessoryStr"];
        }
        
        if (self.bjImageDataArray.count > self.bjTypeIndex) {
            [self.localDict setValue:self.bjImageDataArray[self.bjTypeIndex] forKey:@"bjImage"];
        }
        
        if (self.channelDataArray.count > self.channelTypeIndex) {
            [self.localDict setValue:self.channelDataArray[self.channelTypeIndex] forKey:@"channelStr"];
            [self.localDict setValue:self.channelIdDataArray[self.channelTypeIndex] forKey:@"channelId"];
        }
        
        [self.localDict setValue:self.picIdsArray forKey:@"picIdsArray"];
        [[NSUserDefaults standardUserDefaults] setObject:self.localDict forKey:@"保存设计"];
        
        [GKCover centerCover:view style:GKCoverStyleTranslucent notClick:true animated:true];
        
    }
    if (button.tag == 2002 || button.tag == 2003 || button.tag == 2004) {
        if (!self.sexStr || !self.ageStr || !self.seasonStr || !self.typeStr || !self.sizeStr || !self.accessorieStr || !self.channelStr ) {//|| self.picIdsArray.count != 4
            [HttpManager showNoteMsg:@"请把信息选择完全"];
            return;
        }
        NSMutableArray *idsArr = [NSMutableArray array];
        [idsArr addObject:self.picIdsArray[0]];
        for (int i = 0; i < [self.picIdsArray[1] count]; i++) {
            if ([[NSString stringWithFormat:@"%@",self.picIdsArray[1][i]] length] > 0) {
                [idsArr addObject:self.picIdsArray[1][i]];
            }
        }
        [idsArr addObject:self.picIdsArray[2]];
        
        [HttpManager uploadImageArr:[@[[self convertViewToImage:self.bjImageView]] mutableCopy] success:^(id successResponse) {
            //进入3D发布界面
            ModelingPublishVC *vc = [[ModelingPublishVC alloc] init];
            vc.sexStr = self.sexStr;
            vc.ageStr = self.ageStr;
            vc.seasonStr = self.seasonStr;
            vc.typeStr = self.typeStr;
            vc.sizeStr = self.sizeStr;
            vc.accessoryStr = self.accessorieStr;
            vc.channelStr = self.channelStr;
            if (button.tag == 2002) {
                vc.isWish = YES;
            }else if (button.tag == 2003) {
                vc.isBuy = YES;
            }
            
            //需要传一个整体的效果图
            vc.modelImageUrl = successResponse[0];
            
            vc.channelId = [self.channelId integerValue];
            vc.picIdsArray = idsArr;
            [weakSelf.navigationController pushViewController:vc animated:true];
        }];
    }
}

#pragma mark - 实现tableView的代理和数据源
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (self.typeInt == 3) {
        return 3;
    }else if (self.typeInt == 5 ) {//|| self.typeInt == 6
        return 2;
    }else if (self.typeInt == 1){
        return 2;
    }
    
    return 1;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.typeInt == 3) {
        if (indexPath.row == 0) {
            return ScreenX375(32);
        }else if(indexPath.row == 1){
            return ScreenX375(22);
        }else{
            return ScreenX375(210);
        }
    }else if (self.typeInt == 5) {
        if (indexPath.row == 0) {
            return ScreenX375(22);
        }
        return ScreenX375(210);
    }else if (self.typeInt == 1){
        return indexPath.row == 0 ? ScreenX375(22) :ScreenX375(210);
    }
    return ScreenX375(215);
}

#pragma mark - 选择年龄的点击事件
-(void)ageSelect:(UIButton *)button
{
    //tag:1234+i
    NSLog(@"typeButtonTag----%ld",button.tag);
    self.ageSelectBtn.selected = NO;
    button.selected = YES;
    self.ageSelectBtn = button;
    self.ageSelectNum = button.tag - 1234;
    
    if (self.ageDataAry.count == 0) {
        return;
    }
    
    self.ageStr = self.ageDataAry[button.tag - 1234];
    UIButton * btn = [self.view viewWithTag: 1001];
    [btn setTitle:self.ageStr forState:UIControlStateNormal];
    
    [self.bjImageView setAge:self.ageDataAry[button.tag - 1234]];
    if ([self.ageArr[button.tag - 1234][@"pics"] count] > 0) {
        [self.bjImageView setHeadWithImage:self.ageArr[button.tag - 1234][@"pics"][0][@"head"]];
        [self.bjImageView setClothesWithImage:self.ageArr[button.tag - 1234][@"pics"][0][@"body"]];
        [self.bjImageView setTrousersWithImage:self.ageArr[button.tag - 1234][@"pics"][0][@"foot"]];
    }
    
    NSDictionary *ageDict = self.ageArr[button.tag - 1234];
    NSArray *ageArr = [ageDict valueForKey:@"pics"];
    [self.ageImageDataAry removeAllObjects];
    [self.modelIdDataAry removeAllObjects];
    [self.headPicDataAry removeAllObjects];
    [self.bodyPicDataAry removeAllObjects];
    [self.footPicDataAry removeAllObjects];
    [self.modelPicIdArray removeAllObjects];
    for (NSDictionary *dict in ageArr) {
        [self.ageImageDataAry addObject:dict[@"pic"]];
        [self.modelIdDataAry addObject:dict[@"modelId"]];
        [self.headPicDataAry addObject:dict[@"head"]];
        [self.bodyPicDataAry addObject:dict[@"body"]];
        [self.footPicDataAry addObject:dict[@"foot"]];
        [self.modelPicIdArray addObject:dict[@"id"]];
        
    }
    [self.picIdsArray replaceObjectAtIndex:0 withObject:self.ageArr[self.ageSelectNum][@"pics"][0][@"id"]];
    
    NSIndexPath *indexpath = [NSIndexPath indexPathForRow:1 inSection:0];
    [self.tableView reloadRowsAtIndexPaths:@[indexpath] withRowAnimation:UITableViewRowAnimationNone];
}

#pragma mark - 选择款型的 选择类型的点击事件
-(void)typeSelect:(UIButton *)button
{
    NSLog(@"typeButtonTag----%ld",button.tag);
    self.typeSelectBtn.selected = NO;
    button.selected = YES;
    self.typeSelectBtn = button;
    //记录当时所选的 第几个按钮
    self.typeSelectNum = button.tag - 111;
    
    NSDictionary *typaDict = self.typeArr[button.tag - 111];
    [self.modelImageDataAry removeAllObjects];
    [self.modelIdDataAry removeAllObjects];
    [self.styleSelectArray removeAllObjects];
    //款式类型（短袖长袖，短裤长裤之类的）
    NSArray *typeNamesArr = [typaDict valueForKey:@"typeNames"];
    for (NSDictionary *dict in typeNamesArr) {
        //款式类型
        [self.styleSelectArray addObject:dict[@"typeName"]];
        for (NSDictionary *imageAndIdDict in dict[@"typePics"]) {
            //图片数组
            [self.modelImageDataAry addObject:imageAndIdDict[@"pic"]];
            [self.modelIdDataAry addObject:imageAndIdDict[@"picId"]];
        }
    }
    
    self.styleSelectNum = 0;
    
    [self.typeTitleArray removeObjectAtIndex:3];
    self.typeStr = [self.typeSelectArray[self.typeSelectNum] stringByAppendingString:self.styleSelectArray[self.styleSelectNum]];
    [self.typeTitleArray insertObject:self.typeStr atIndex:3];
    [[self.view viewWithTag:1003] setTitle:self.typeStr forState:UIControlStateNormal];
    
    self.typeTypeIndex = 0;
    if ([self.typeSelectArray[self.typeSelectNum] isEqualToString:@"上衣"]) {
        [self.bjImageView setClothesWithImage:self.modelImageDataAry[0]];
        
        [self.localDict setValue:self.modelImageDataAry[self.typeSelectNum] forKey:@"typeImage"];
    }else if ([self.typeSelectArray[self.typeSelectNum] isEqualToString:@"下衣"]) {
        [self.bjImageView setTrousersWithImage:self.modelImageDataAry[0]];
        
        [self.localDict setValue:self.modelImageDataAry[self.typeSelectNum] forKey:@"styleImage"];
    }
    if ([self.picIdsArray[1] count] == 0) {
        return;
    }
    NSMutableArray *array = [NSMutableArray arrayWithArray:self.picIdsArray[1]];
    [array replaceObjectAtIndex:self.typeSelectNum withObject:self.modelIdDataAry[0]];
    [self.picIdsArray replaceObjectAtIndex:1 withObject:array];
    
    NSIndexPath *indexpath1 = [NSIndexPath indexPathForRow:1 inSection:0];
    NSIndexPath *indexpath2 = [NSIndexPath indexPathForRow:2 inSection:0];
    [self.tableView reloadRowsAtIndexPaths:@[indexpath1,indexpath2] withRowAnimation:UITableViewRowAnimationNone];
    NSLog(@"typeInt----%ld",self.typeInt);
}

#pragma mark - 选择款型的 选择款型的点击事件
-(void)styleSelect:(UIButton *)button
{
    NSLog(@"styleButtonTag----%ld",button.tag);
    //默认选中的是第一个，当点击别的按钮的时候，要给选中的按钮的选中状态去掉
    self.styleSelectBtn.selected = NO;
    //此时点击的这个按钮的状态要改变为选中状态
    button.selected = YES;
    //此时选中的按钮就是当前点击的这个按钮了
    self.styleSelectBtn = button;
    //记录当时所选的 第几个按钮
    self.styleSelectNum = button.tag - 222;
    
    [self.typeTitleArray removeObjectAtIndex:3];
    self.typeStr = [self.typeSelectArray[self.typeSelectNum] stringByAppendingString:self.styleSelectArray[self.styleSelectNum]];
    [self.typeTitleArray insertObject:self.typeStr atIndex:3];
    [[self.view viewWithTag:1003] setTitle:self.typeStr forState:UIControlStateNormal];
    
    NSIndexPath *indexpath = [NSIndexPath indexPathForRow:2 inSection:0];
    [self.tableView reloadRowsAtIndexPaths:@[indexpath] withRowAnimation:(UITableViewRowAnimationNone)];
    NSLog(@"typeInt----%ld",self.typeInt);
}

#pragma mark - 选择配饰的 点击事件
-(void)accessorySelect:(UIButton *)button
{
    NSLog(@"styleButtonTag----%ld",button.tag);
    self.accessorySelectBtn.selected = NO;
    button.selected = YES;
    self.accessorySelectBtn = button;
    self.accessorySelectNum = button.tag - 555;
    
    NSDictionary *accessoryDict = self.accessoryArr[self.accessorySelectNum];
    [self.accessoryImageDataAry removeAllObjects];
    [self.accessoryIdDataAry removeAllObjects];
    for (NSDictionary *dic in [accessoryDict valueForKey:@"pics"]) {
        [self.accessoryImageDataAry addObject:[dic valueForKey:@"pic"]];
        [self.accessoryIdDataAry addObject:[dic valueForKey:@"picId"]];
    }
    
    [self.typeTitleArray removeObjectAtIndex:5];
    [self.typeTitleArray insertObject:self.accessoryDataAry[self.accessorySelectNum] atIndex:5];
    self.accessorieStr = self.accessoryDataAry[self.accessorySelectNum];
    [[self.view viewWithTag:1005] setTitle:self.accessoryDataAry[self.accessorySelectNum] forState:UIControlStateNormal];
    
    if (self.accessoryIdDataAry.count > 0) {
        [self.picIdsArray replaceObjectAtIndex:2 withObject:self.accessoryIdDataAry[0]];
    }
    
    NSIndexPath *indexpath = [NSIndexPath indexPathForRow:1 inSection:0];
    [self.tableView reloadRowsAtIndexPaths:@[indexpath] withRowAnimation:UITableViewRowAnimationNone];
    NSLog(@"typeInt----%ld",self.typeInt);
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    __weak __typeof(self) weakSelf = self;
    if (self.typeInt == 0) {
        NSArray *sexPicArr = @[@"男",@"女"];
        ThreeDPublishCell *cell = [ThreeDPublishCell cellWithTableView:tableView andIndexPath:indexPath andCellHeight:ScreenX375(210) andTitleArray:self.sexStrArr andBjImageArray:sexPicArr lines:1 itemCount:self.sexStrArr.count andCellId:@"ThreeDSexPublishCell" andItemHeight:ScreenX375(210) andTypeInt:self.typeInt];
        cell.selectClickBlock = ^(NSInteger indexSelectRow) {
            weakSelf.sexTypeIndex = indexSelectRow;
            weakSelf.typeInt = indexSelectRow;
            [weakSelf.typeTitleArray removeObjectAtIndex:0];
            [weakSelf.typeTitleArray insertObject:weakSelf.sexStrArr[weakSelf.sexTypeIndex] atIndex:0];
            weakSelf.sexStr = weakSelf.sexStrArr[weakSelf.sexTypeIndex];
            [weakSelf.bjImageView setSex:weakSelf.sexStrArr[weakSelf.sexTypeIndex]];
            [[weakSelf.view viewWithTag:1000] setTitle:weakSelf.sexStrArr[weakSelf.sexTypeIndex] forState:UIControlStateNormal];
        };
        return cell;
    }else if (self.typeInt == 1) {
        if (indexPath.row == 0) {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AgeCellID"];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"AgeCellID"];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                
                self.ageBjScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScreenX375(22))];
                self.ageBjScroll.scrollEnabled = YES;
                self.ageBjScroll.userInteractionEnabled = YES;
                self.ageBjScroll.showsVerticalScrollIndicator = false;
                self.ageBjScroll.showsHorizontalScrollIndicator = false;
                self.ageBjScroll.delegate = self;
                [cell addSubview:self.ageBjScroll];
                
            }
            [self.ageBjScroll setContentSize:CGSizeMake(self.ageDataAry.count*ScreenX375(86)+ScreenX375(82), ScreenX375(22))];
            for (UIView *subView in self.ageBjScroll.subviews) {
                [subView removeFromSuperview];
            }
            
            for (int i = 0; i< self.ageDataAry.count; i ++) {
                UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
                button.frame = CGRectMake(ScreenX375(50)+i*(ScreenX375(16)+ScreenX375(70)), ScreenX375(0), ScreenX375(70), ScreenX375(22));
                button.titleLabel.font = Kfont(13);
                button.tag = 1234+i;
                [button setTitle:self.ageDataAry[i] forState:UIControlStateNormal];
                [button setTitleColor:UIColorFromRGB(@"#888888", 1) forState:UIControlStateNormal];
                [button setTitleColor:UIColorFromRGB(@"#f43950", 1) forState:UIControlStateSelected];
                if (i == 0) {
                    button.selected = YES;
                    self.ageSelectBtn = button;
                    NSDictionary *ageDict = self.ageArr[i];
                    NSArray *ageArr = [ageDict valueForKey:@"pics"];
                    [self.ageImageDataAry removeAllObjects];
                    for (NSDictionary *dict in ageArr) {
                        [self.ageImageDataAry addObject:dict[@"pic"]];
                    }
                }
                [button addTarget:self action:@selector(ageSelect:) forControlEvents:UIControlEventTouchUpInside];
                
                [self.ageBjScroll addSubview:button];
            }
            return cell;
        }else{
            ThreeDPublishCell *cell = [ThreeDPublishCell cellWithTableView:tableView andIndexPath:indexPath andCellHeight:ScreenX375(210) andTitleArray:self.ageImageDataAry andBjImageArray:self.ageImageDataAry lines:1 itemCount:self.ageImageDataAry.count andCellId:@"ThreeDAgePublishCell" andItemHeight:ScreenX375(210) andTypeInt:self.typeInt];
            cell.selectClickBlock = ^(NSInteger indexSelectRow) {
                weakSelf.ageTypeIndex = indexSelectRow;
                [weakSelf.bjImageView setAge:self.ageDataAry[weakSelf.ageSelectNum]];
                [weakSelf.bjImageView setHeadWithImage:weakSelf.ageArr[weakSelf.ageSelectNum][@"pics"][weakSelf.ageTypeIndex][@"head"]];
                [weakSelf.bjImageView setClothesWithImage:weakSelf.ageArr[weakSelf.ageSelectNum][@"pics"][weakSelf.ageTypeIndex][@"body"]];
                [weakSelf.bjImageView setTrousersWithImage:weakSelf.ageArr[weakSelf.ageSelectNum][@"pics"][weakSelf.ageTypeIndex][@"foot"]];
                [weakSelf.picIdsArray replaceObjectAtIndex:0 withObject:weakSelf.ageArr[weakSelf.ageSelectNum][@"pics"][weakSelf.ageTypeIndex][@"id"]];
            };
            return cell;
        }
    }else if (self.typeInt == 2) {
        NSArray *seasonStrArr = @[@"春",@"夏",@"秋",@"冬"];
        NSArray *seasonPicArr = @[@"春天",@"夏天",@"秋天",@"冬天"];
        ThreeDPublishCell *cell = [ThreeDPublishCell cellWithTableView:tableView andIndexPath:indexPath andCellHeight:ScreenX375(210) andTitleArray:seasonStrArr andBjImageArray:seasonPicArr lines:2 itemCount:seasonStrArr.count andCellId:@"ThreeDSeasonPublishCell" andItemHeight:ScreenX375(105) andTypeInt:self.typeInt];
        cell.selectClickBlock = ^(NSInteger indexSelectRow) {
            weakSelf.seasonTypeIndex = indexSelectRow;
            [weakSelf.typeTitleArray removeObjectAtIndex:2];
            [weakSelf.typeTitleArray insertObject:seasonStrArr[weakSelf.seasonTypeIndex] atIndex:2];
            weakSelf.seasonStr = seasonStrArr[weakSelf.seasonTypeIndex];
            [[weakSelf.view viewWithTag:1002] setTitle:seasonStrArr[weakSelf.seasonTypeIndex] forState:UIControlStateNormal];
        };
        
        return cell;
    }else if (self.typeInt == 3) {
        if (indexPath.row == 0) {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TypeCellID"];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TypeCellID"];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            
            for (UIView *subView in cell.subviews) {
                [subView removeFromSuperview];
            }
            
            self.typeBjScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScreenX375(22))];
            self.typeBjScroll.scrollEnabled = YES;
            self.typeBjScroll.tag = 33333;
            self.typeBjScroll.userInteractionEnabled = YES;
            self.typeBjScroll.showsVerticalScrollIndicator = false;
            self.typeBjScroll.showsHorizontalScrollIndicator = false;
            self.typeBjScroll.delegate = self;
            [cell addSubview:self.typeBjScroll];
            [self.typeBjScroll setContentSize:CGSizeMake(self.typeSelectArray.count*ScreenX375(86)+ScreenX375(82), ScreenX375(22))];
            
            UILabel *typeLabel = [[UILabel alloc] init];
            typeLabel.frame = CGRectMake(ScreenX375(12), ScreenX375(0), ScreenX375(70), ScreenX375(22));
            typeLabel.text = @"选择类别:";
            typeLabel.textColor = UIColorFromRGB(@"#666666", 1);
            typeLabel.font = Kfont(13);
            [self.typeBjScroll addSubview:typeLabel];
            
            for (int i = 0; i< self.typeSelectArray.count; i ++) {
                UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
                button.frame = CGRectMake(typeLabel.right+i*(ScreenX375(16)+ScreenX375(70)), ScreenX375(0), ScreenX375(70), ScreenX375(22));
                button.titleLabel.font = Kfont(13);
                button.layer.masksToBounds = YES;
                button.layer.cornerRadius = 11.0;
                button.layer.borderWidth = 1.0;
                [button hcb_setborderColor:UIColorFromRGB(@"#888888", 1) forState:UIControlStateNormal animated:NO];
                [button hcb_setborderColor:UIColorFromRGB(@"#f43950", 1) forState:UIControlStateSelected animated:NO];
                button.tag = 111+i;
                [button setTitle:self.typeSelectArray[i] forState:UIControlStateNormal];
                [button setTitleColor:UIColorFromRGB(@"#888888", 1) forState:UIControlStateNormal];
                [button setTitleColor:UIColorFromRGB(@"#f43950", 1) forState:UIControlStateSelected];
                if (i == 0) {
                    button.selected = YES;
                    self.typeSelectBtn = button;
                    
                }
                [button addTarget:self action:@selector(typeSelect:) forControlEvents:UIControlEventTouchUpInside];
                
                [self.typeBjScroll addSubview:button];
            }
            return cell;
        }else if (indexPath.row == 1){
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"StyleCellID"];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"StyleCellID"];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            
            for (UIView *subView in cell.subviews) {
                [subView removeFromSuperview];
            }
            
            self.styleBjScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScreenX375(22))];
            self.styleBjScroll.scrollEnabled = YES;
            self.styleBjScroll.tag = 44444;
            self.styleBjScroll.userInteractionEnabled = YES;
            self.styleBjScroll.showsVerticalScrollIndicator = false;
            self.styleBjScroll.showsHorizontalScrollIndicator = false;
            self.styleBjScroll.delegate = self;
            [cell addSubview:self.styleBjScroll];
            [self.styleBjScroll setContentSize:CGSizeMake(self.styleSelectArray.count*ScreenX375(86)+ScreenX375(82), ScreenX375(22))];
            
            UILabel *styleLabel = [[UILabel alloc] init];
            styleLabel.frame = CGRectMake(ScreenX375(12), ScreenX375(0), ScreenX375(70), ScreenX375(22));
            styleLabel.text = @"选择款型:";
            styleLabel.textColor = UIColorFromRGB(@"#666666", 1);
            styleLabel.font = Kfont(13);
            [self.styleBjScroll addSubview:styleLabel];
            
            for (int i = 0; i< self.styleSelectArray.count; i ++) {
                UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
                button.frame = CGRectMake(styleLabel.right+i*(ScreenX375(16)+ScreenX375(70)), ScreenX375(0), ScreenX375(70), ScreenX375(22));
                button.titleLabel.font = Kfont(13);
                button.tag = 222+i;
                button.layer.masksToBounds = YES;
                button.layer.cornerRadius = 11.0;
                button.layer.borderWidth = 1.0;
                [button hcb_setborderColor:UIColorFromRGB(@"#888888", 1) forState:UIControlStateNormal animated:NO];
                [button hcb_setborderColor:UIColorFromRGB(@"#f43950", 1) forState:UIControlStateSelected animated:NO];
                [button setTitle:self.styleSelectArray[i] forState:UIControlStateNormal];
                [button setTitleColor:UIColorFromRGB(@"#888888", 1) forState:UIControlStateNormal];
                [button setTitleColor:UIColorFromRGB(@"#f43950", 1) forState:UIControlStateSelected];
                
                if (i == 0) {
                    button.selected = YES;
                    self.styleSelectBtn = button;
                }
                [button addTarget:self action:@selector(styleSelect:) forControlEvents:UIControlEventTouchUpInside];
                [self.styleBjScroll addSubview:button];
            }
            return cell;
        }else{
            
            ThreeDPublishCell *cell = [ThreeDPublishCell cellWithTableView:tableView andIndexPath:indexPath andCellHeight:ScreenX375(210) andTitleArray:self.modelImageDataAry andBjImageArray:self.modelImageDataAry lines:1 itemCount:self.modelImageDataAry.count andCellId:@"ThreeDTypePublishCell" andItemHeight:ScreenX375(210) andTypeInt:self.typeInt];
            
            cell.selectClickBlock = ^(NSInteger indexSelectRow) {
                weakSelf.typeTypeIndex = indexSelectRow;
                if ([weakSelf.typeSelectArray[weakSelf.typeSelectNum] isEqualToString:@"上衣"]) {
                    
                    [weakSelf.localDict setValue:weakSelf.modelImageDataAry[indexSelectRow] forKey:@"typeImage"];
                    [weakSelf.bjImageView setClothesWithImage:weakSelf.modelImageDataAry[indexSelectRow]];
                    
                }else if ([weakSelf.typeSelectArray[weakSelf.typeSelectNum] isEqualToString:@"下衣"]) {
                    
                    [weakSelf.localDict setValue:weakSelf.modelImageDataAry[indexSelectRow] forKey:@"styleImage"];
                    [weakSelf.bjImageView setTrousersWithImage:weakSelf.modelImageDataAry[indexSelectRow]];
                    
                }
                if ([self.picIdsArray[1] count] == 0) {
                    return ;
                }
                NSMutableArray *array = [NSMutableArray arrayWithArray:weakSelf.picIdsArray[1]];
                [array replaceObjectAtIndex:self.typeSelectNum withObject:self.modelIdDataAry[weakSelf.typeTypeIndex]];
                [self.picIdsArray replaceObjectAtIndex:1 withObject:array];
            };
            return cell;
        }
    }else if (self.typeInt == 4) {

        ThreeDPublishCell *cell = [ThreeDPublishCell cellWithTableView:tableView andIndexPath:indexPath andCellHeight:ScreenX375(210) andTitleArray:self.sizeDataAry andBjImageArray:self.sizeDataAry lines:1 itemCount:self.sizeDataAry.count andCellId:@"ThreeDSizePublishCell" andItemHeight:ScreenX375(210) andTypeInt:self.typeInt];

        cell.selectClickBlock = ^(NSInteger indexSelectRow) {
            weakSelf.sizeTypeIndex = indexSelectRow;
            [weakSelf.typeTitleArray removeObjectAtIndex:4];
            [weakSelf.typeTitleArray insertObject:self.sizeDataAry[weakSelf.sizeTypeIndex] atIndex:4];
            weakSelf.sizeStr = self.sizeDataAry[weakSelf.sizeTypeIndex];
            [[weakSelf.view viewWithTag:1004] setTitle:self.sizeDataAry[weakSelf.sizeTypeIndex] forState:UIControlStateNormal];
        };
        
        return cell;
    }else if (self.typeInt == 5) {
        if (indexPath.row == 0) {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"accessoryCell"];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"accessoryCell"];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                
                self.accessoryBjScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScreenX375(22))];
                self.accessoryBjScroll.scrollEnabled = YES;
                self.accessoryBjScroll.tag = 55555;
                self.accessoryBjScroll.userInteractionEnabled = YES;
                self.accessoryBjScroll.showsVerticalScrollIndicator = false;
                self.accessoryBjScroll.showsHorizontalScrollIndicator = false;
                self.accessoryBjScroll.delegate = self;
                [self.accessoryBjScroll setContentSize:CGSizeMake(self.accessoryDataAry.count*ScreenX375(86)+ScreenX375(12), ScreenX375(22))];
                [cell addSubview:self.accessoryBjScroll];
            }
            for (UIView *subView in self.accessoryBjScroll.subviews) {
                [subView removeFromSuperview];
            }

            for (int i = 0; i < self.accessoryDataAry.count; i ++) {
                UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
                button.frame = CGRectMake(ScreenX375(12)+i*(ScreenX375(16)+ScreenX375(70)), ScreenX375(0), ScreenX375(70), ScreenX375(22));
                button.titleLabel.font = Kfont(13);
                button.tag = 555+i;
                [button setTitle:self.accessoryDataAry[i] forState:UIControlStateNormal];
                [button setTitleColor:UIColorFromRGB(@"#888888", 1) forState:UIControlStateNormal];
                [button setTitleColor:UIColorFromRGB(@"#f43950", 1) forState:UIControlStateSelected];
                if (i == 0) {
                    button.selected = YES;
                    self.accessorySelectBtn = button;
                    NSDictionary *accessoryDict = self.accessoryArr[0];
                    [self.accessoryImageDataAry removeAllObjects];
                    [self.accessoryIdDataAry removeAllObjects];
                    for (NSDictionary *dic in [accessoryDict valueForKey:@"pics"]) {
                        [self.accessoryImageDataAry addObject:[dic valueForKey:@"pic"]];
                        [self.accessoryIdDataAry addObject:[dic valueForKey:@"picId"]];
                    }
                }
                [button addTarget:self action:@selector(accessorySelect:) forControlEvents:UIControlEventTouchUpInside];
                
                [self.accessoryBjScroll addSubview:button];
            }
            return cell;
        }else{
            ThreeDPublishCell *cell = [ThreeDPublishCell cellWithTableView:tableView andIndexPath:indexPath andCellHeight:ScreenX375(210) andTitleArray:self.accessoryDataAry andBjImageArray:self.accessoryImageDataAry lines:1 itemCount:self.accessoryImageDataAry.count andCellId:@"ThreeDAccessoriesPublishCell" andItemHeight:ScreenX375(210) andTypeInt:self.typeInt];

            cell.selectClickBlock = ^(NSInteger indexSelectRow) {
                weakSelf.accessoriesTypeIndex = indexSelectRow;
                [weakSelf.picIdsArray replaceObjectAtIndex:2 withObject:weakSelf.accessoryIdDataAry[indexSelectRow]];
            };
            
            return cell;
        }
    }else if (self.typeInt == 6) {

        ThreeDPublishCell *cell = [ThreeDPublishCell cellWithTableView:tableView andIndexPath:indexPath andCellHeight:ScreenX375(210) andTitleArray:self.bjImageDataArray andBjImageArray:self.bjImageDataArray lines:1 itemCount:self.bjImageDataArray.count andCellId:@"ThreeDBjPublishCell" andItemHeight:ScreenX375(210) andTypeInt:self.typeInt];

        cell.selectClickBlock = ^(NSInteger indexSelectRow) {
            weakSelf.bjTypeIndex = indexSelectRow;
            [weakSelf.bjImageView setBackGroundWithImage:weakSelf.bjImageDataArray[weakSelf.bjTypeIndex]];
        };
        return cell;
    }else{
        ThreeDPublishCell *cell = [ThreeDPublishCell cellWithTableView:tableView andIndexPath:indexPath andCellHeight:ScreenX375(210) andTitleArray:self.channelDataArray andBjImageArray:self.channelImageDataArray lines:1 itemCount:self.channelDataArray.count andCellId:@"ThreeDChannelPublishCell" andItemHeight:ScreenX375(210) andTypeInt:self.typeInt];

        cell.selectClickBlock = ^(NSInteger indexSelectRow) {
            weakSelf.channelTypeIndex = indexSelectRow;
            [weakSelf.typeTitleArray removeObjectAtIndex:7];
            [weakSelf.typeTitleArray insertObject:self.channelDataArray[weakSelf.channelTypeIndex] atIndex:7];
            weakSelf.channelStr = weakSelf.channelDataArray[weakSelf.channelTypeIndex];
            weakSelf.channelId = weakSelf.channelIdDataArray[weakSelf.channelTypeIndex];
            [[weakSelf.view viewWithTag:1007] setTitle:self.channelDataArray[weakSelf.channelTypeIndex] forState:UIControlStateNormal];
        };
        
        return cell;
    }
}

- (void)share {
    if (!self.shareView) {
        self.shadowBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        self.shadowBtn.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
        [self.shadowBtn addTarget:self action:@selector(hidden) forControlEvents:UIControlEventTouchUpInside];
        self.shadowBtn.hidden = YES;
        [kKeyWindow addSubview:self.shadowBtn];
        
        self.shareView = [[ShareView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT , SCREEN_WIDTH, ScreenX375(180))];
        __weak __typeof(self) weakSelf = self;
        self.shareView.cancel = ^{
            [weakSelf hidden];
        };
        self.shareView.wxClick = ^{
            SendMessageToWXReq *sendReq = [[SendMessageToWXReq alloc] init];
            sendReq.bText = NO;
            sendReq.scene = 0;
            
            // 2.创建分享内容
            WXMediaMessage *message = [WXMediaMessage message];
            //分享标题
            message.title = @"虾拼";
            // 描述
            message.description = @"全球好货，等您来代购";
            //分享图片,使用SDK的setThumbImage方法可压缩图片大小
            //                message.thumbData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMAGEHEADER,self.model.pics.firstObject]]];
            [message setThumbImage:[UIImage imageNamed:@"虾拼 logo"]];
            
            //创建多媒体对象
            WXWebpageObject *webObj = [WXWebpageObject object];
            // 点击后的跳转链接
            webObj.webpageUrl = @"http://www.baidu.com";
            message.mediaObject = webObj;
            sendReq.message = message;
            [WXApi sendReq:sendReq];
        };
        self.shareView.wxGroupClick = ^{
            SendMessageToWXReq *sendReq = [[SendMessageToWXReq alloc] init];
            sendReq.bText = NO;
            sendReq.scene = 1;
            
            // 2.创建分享内容
            WXMediaMessage *message = [WXMediaMessage message];
            //分享标题
            message.title = @"虾拼";
            // 描述
            message.description = @"全球好货，等您来代购";
            //分享图片,使用SDK的setThumbImage方法可压缩图片大小
            [message setThumbImage:[UIImage imageNamed:@"虾拼 logo"]];
            
            //创建多媒体对象
            WXWebpageObject *webObj = [WXWebpageObject object];
            // 点击后的跳转链接
            webObj.webpageUrl = @"http://www.baidu.com";
            message.mediaObject = webObj;
            sendReq.message = message;
            [WXApi sendReq:sendReq];
        };
        self.shareView.qqClick = ^{
            weakSelf.tencentOAuth = [[TencentOAuth alloc] initWithAppId:kQQAppKey andDelegate:weakSelf];
            
            NSString *url = @"http://www.baidu.com";
            NSString *imageUrl = [NSString stringWithFormat:@"%@",IMAGEHEADER];
            
            QQApiNewsObject *share = [QQApiNewsObject objectWithURL:[NSURL URLWithString:url] title:@"虾拼" description:@"全球好货，等您来代购" previewImageURL:[NSURL URLWithString:imageUrl]];
            SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:share];
            
            //分享到qq
            [QQApiInterface sendReq:req];
        };
        self.shareView.wbClick = ^{
            //微博
            WBMessageObject *message = [WBMessageObject message];
            message.text = @"虾拼";
            
            WBAuthorizeRequest *authRequest = [WBAuthorizeRequest request];
            authRequest.redirectURI = kWeiboAppRedirectURL;
            authRequest.scope = @"all";
            
            WBSendMessageToWeiboRequest *sharerequest = [WBSendMessageToWeiboRequest requestWithMessage:message authInfo:authRequest access_token:nil];
            [WeiboSDK sendRequest:sharerequest];
        };
        [kKeyWindow addSubview:self.shareView];
    }
    self.shadowBtn.hidden = NO;
    [UIView animateWithDuration:0.3 animations:^{
        self.shareView.frame = CGRectMake(0, SCREEN_HEIGHT - ScreenX375(180), SCREEN_WIDTH, ScreenX375(180));
    }];
}

- (void)hidden
{
    [UIView animateWithDuration:0.3 animations:^{
        self.shareView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, ScreenX375(180));
    } completion:^(BOOL finished) {
        self.shadowBtn.hidden = YES;
    }];
}

-(UIImage*)convertViewToImage:(UIView*)v{
    CGSize s = v.bounds.size;
    // 下面方法，第一个参数表示区域大小。第二个参数表示是否是非透明的。如果需要显示半透明效果，需要传NO，否则传YES。第三个参数就是屏幕密度了
    UIGraphicsBeginImageContextWithOptions(s, NO, [UIScreen mainScreen].scale);
    [v.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage*image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

@end

/*
 ///如果之前保存过，重新选择后再次保存那就要把里面的东西remove
 //        if ([[NSUserDefaults standardUserDefaults] objectForKey:@"保存设计"]) {
 //            NSMutableDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"保存设计"];
 //            [dict removeAllObjects];
 //            dict = [@{@"sex":self.sexStr ,@"age":self.ageDataAry[self.ageSelectNum],@"ageId":self.ageIdDataAry[self.ageSelectNum], @"agePic":self.ageImageDataAry[self.ageTypeIndex],@"head":self.headPicDataAry[self.ageTypeIndex],@"body":self.bodyPicDataAry[self.ageTypeIndex],@"foot":self.footPicDataAry[self.ageTypeIndex], @"season":self.seasonStr,@"size":self.sizeDataAry[self.sizeTypeIndex],@"accessory":self.accessoryDataAry[self.accessorySelectNum],@"accessoryPicsId":self.accessoryImageDataAry[self.accessoriesTypeIndex],@"bj":self.bjImageDataArray[self.bjTypeIndex],@"channel":self.channelStr,@"channelId":self.channelIdDataArray[self.channelTypeIndex],@"isSave":@(YES)} mutableCopy];
 //            if ([self.picIdsArray[1] count] == 2) {
 //                NSInteger topBodyId = [self.picIdsArray[1][0] integerValue];
 //                NSInteger bottomBodyId = [self.picIdsArray[1][1] integerValue];
 //                [dict setValue:@(topBodyId) forKey:@"typeId"];
 //                [dict setValue:@(bottomBodyId) forKey:@"styleId"];
 //
 //            }else{
 //                NSInteger topBodyId = [self.picIdsArray[1][0] integerValue];
 //                [dict setValue:@(topBodyId) forKey:@"typeId"];
 //            }
 //        }else{
 //        self.localDict = [@{@"sex":self.sexStr ,@"age":self.ageDataAry[self.ageSelectNum],@"ageId":self.ageIdDataAry[self.ageSelectNum], @"agePic":self.ageImageDataAry[self.ageTypeIndex],@"head":self.headPicDataAry[self.ageTypeIndex],@"body":self.bodyPicDataAry[self.ageTypeIndex],@"foot":self.footPicDataAry[self.ageTypeIndex], @"season":self.seasonStr,@"size":self.sizeDataAry[self.sizeTypeIndex],@"accessory":self.accessoryDataAry[self.accessorySelectNum],@"accessoryPicsId":self.accessoryImageDataAry[self.accessoriesTypeIndex],@"bj":self.bjImageDataArray[self.bjTypeIndex],@"channel":self.channelStr,@"channelId":self.channelIdDataArray[self.channelTypeIndex],@"isSave":@(YES)} mutableCopy];
 //        if ([self.picIdsArray[1] count] == 2) {
 //            NSInteger topBodyId = [self.picIdsArray[1][0] integerValue];
 //            NSInteger bottomBodyId = [self.picIdsArray[1][1] integerValue];
 //            [self.localDict setValue:@(topBodyId) forKey:@"typeId"];
 //            [self.localDict setValue:@(bottomBodyId) forKey:@"styleId"];
 //
 //        }else{
 //            NSInteger topBodyId = [self.picIdsArray[1][0] integerValue];
 //            [self.localDict setValue:@(topBodyId) forKey:@"typeId"];
 //        }
 */

